#!/usr/bin/env python 
# -*- coding:utf-8 -*-
"""
@Time:2022/3/6 下午5:54"
@Author:lydia_liu"
@File:product_edit_page.py
@function:商品编辑页面
"""
from selenium.webdriver.common.by import By

from litemallPrac.page.base_page import BasePage
from litemallPrac.page.product_list_page import ProductListPage


class ProductEdit(BasePage):

    _update_product_name = (By.XPATH,'//*[@for="name"]/..//input','更新商品0308')

    _button_updateproduct = (By.XPATH,'//span[contains(text(),"更新商品")]')
    def update_product(self):

        #编辑商品页面，修改商品名称
        self.sendkeys(*self._update_product_name)
        #滑动到底部
        self.driver.execute_script('window.scrollTo(0, document.body.scrollHeight)')
        #点击更新按钮
        self.on_click(*self._button_updateproduct)

        return ProductListPage(self.driver)
